﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace KTV.after
{
    public partial class chaxungesho : Form
    {
        public chaxungesho()
        {
            InitializeComponent();
        }
        //窗体加载的事件
        private void chaxungesho_Load(object sender, EventArgs e)
        {
            banding();

        }
        //连接数据库
        string loanjie = "Data Source=172.16.1.45;Initial Catalog=DB_A2011_G02;Persist Security Info=True;User ID=a2011;Password=Abcd_!23^ ";
       
        DataSet ll = new DataSet();
        SqlConnection sqlConnection = null;
        string sql1 = "SELECT [name],[liebie],[sex],[zhaopian]FROM[DB_A2011_G02].[dbo].[geshoubiao]";
       
        //查询歌手信息
        public void banding()
        {
            if(ll.Tables["geshoubiao"]!=null)
            {
                ll.Tables["geshoubiao"].Clear();

            }
            sqlConnection = new SqlConnection(loanjie);
            SqlDataAdapter adapter = new SqlDataAdapter(sql1, sqlConnection);

            try
            {
                ll.Tables.Clear();
                adapter.Fill(ll,"geshoubiao");
                dataGridView1.DataSource = ll.Tables["geshoubiao"];


            }
            catch (Exception)
            {

                throw;
            }

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
